﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_2016_MaximumDifference
{
    class MainProject
    {
        static void Main(string[] args)
        {
            Console.WriteLine(MaximumDifference(new int[] { 1, 5, 2, 10 }));
            Console.ReadKey();

        }
        public static int MaximumDifference(int[] nums)
        {
            int max = int.MinValue;
            for (int i = 0; i < nums.Length; i++)
            {
                for (int j = i+1; j < nums.Length; j++)
                {
                    int delta  = nums[j] - nums[i];
                    if (delta >0&& delta>max)
                    {
                        max = delta;
                    }
                }
            }
            if (max == int.MinValue) return -1;
            return max;
        }
    }
}
